<?php
	include "include/common.inc.php";

	$errorMsg = "";

	if(isset($_POST["login"]) and $_POST["login"]){
		//echo "<h1>Thank you for Logining In </h1>";
		$user = User::getUserByEmail($_POST["email"]);
		
		if($user->getValue("id") == -1)
			$errorMsg = "None existing User";
		else if($user->getValue("password") != password($_POST["password"]))
			$errorMsg = "Wrong Password";
		else{
			processLogin($user);
			goToUrl("index.php");
		}
	}
?>
<!DOCTYPE html>
<!-- saved from url=(0040)http://getbootstrap.com/examples/signin/ -->
<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <!--link rel="shortcut icon" href="http://getbootstrap.com/assets/ico/favicon.ico"-->
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon">
    <title>Blind Dating</title>

    <!-- Bootstrap core CSS -->
    <link href="http://getbootstrap.com/dist/css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="http://getbootstrap.com/examples/signin/signin.css" rel="stylesheet">

    <!-- Just for debugging purposes. Don't actually copy this line! -->
    <!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>

  <body>
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
  <div class="container-fluid">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="index.php">NUS Blind Dating Site</a>
    </div>
	<ul class="nav navbar-nav">
        <li><a href="index.php">Home</a></li>
        <li><a href="Login.php">Login</a></li>
		<li><a href="Register.php">Register</a></li>
	</ul>
	</div>
	
</nav>

    <div class="container">
     <div class="error"><h2><?php echo $errorMsg; ?></h2></div>
      <form action ="" method= "post" class="form-signin" role="form">
        <h2 class="form-signin-heading">Please login</h2>
        <input type="email" class="form-control" placeholder="Email address" required="" autofocus="" name="email">
        <input type="password" class="form-control" placeholder="Password" required="" name="password">
          <input type="checkbox" value="remember-me">
		  <label> remember me</label>
        <button class="btn btn-lg btn-primary btn-block" type="submit" name ="login" value="login">login</button>
      </form>
    </div>


    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
  

</body>
</html>